

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Brokerage &mdash; quanttrader 0.5.0 documentation</title>
  

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />

  
  
  
  

  
  <!--[if lt IE 9]>
    <script src="_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script src="_static/jquery.js"></script>
        <script src="_static/underscore.js"></script>
        <script src="_static/doctools.js"></script>
        <script src="_static/language_data.js"></script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Data" href="data.html" />
    <link rel="prev" title="Orders Supported" href="ordertype.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="index.html" class="icon icon-home" alt="Documentation Home"> quanttrader
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="backtest.html">Backtest</a></li>
<li class="toctree-l1"><a class="reference internal" href="livetrading.html">Live Trading</a></li>
<li class="toctree-l1"><a class="reference internal" href="instrument.html">Instruments Supported</a></li>
<li class="toctree-l1"><a class="reference internal" href="ordertype.html">Orders Supported</a></li>
</ul>
<p class="caption"><span class="caption-text">Codes</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Brokerage</a></li>
<li class="toctree-l1"><a class="reference internal" href="data.html">Data</a></li>
<li class="toctree-l1"><a class="reference internal" href="event.html">Event</a></li>
<li class="toctree-l1"><a class="reference internal" href="gui.html">GUI</a></li>
<li class="toctree-l1"><a class="reference internal" href="order.html">Order</a></li>
<li class="toctree-l1"><a class="reference internal" href="performance.html">Performance</a></li>
<li class="toctree-l1"><a class="reference internal" href="position.html">Position</a></li>
<li class="toctree-l1"><a class="reference internal" href="risk.html">Risk</a></li>
<li class="toctree-l1"><a class="reference internal" href="strategy.html">Strategy</a></li>
<li class="toctree-l1"><a class="reference internal" href="tradingengine.html">Trading Engine</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">quanttrader</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
        
      <li>Brokerage</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/brokerage.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="brokerage">
<h1>Brokerage<a class="headerlink" href="#brokerage" title="Permalink to this headline">¶</a></h1>
<dl class="py class">
<dt id="quanttrader.brokerage.backtest_brokerage.BacktestBrokerage">
<em class="property">class </em><code class="sig-prename descclassname">quanttrader.brokerage.backtest_brokerage.</code><code class="sig-name descname">BacktestBrokerage</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">events_engine</span></em>, <em class="sig-param"><span class="n">data_board</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.backtest_brokerage.BacktestBrokerage" title="Permalink to this definition">¶</a></dt>
<dd><p>Market order is immediately filled.
Limit or stop order is saved to _active_orders for next tick</p>
<dl class="py method">
<dt id="quanttrader.brokerage.backtest_brokerage.BacktestBrokerage.__init__">
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">events_engine</span></em>, <em class="sig-param"><span class="n">data_board</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.backtest_brokerage.BacktestBrokerage.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize Backtest Brokerage.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>events_engine</strong> – send fill_event to event engine</p></li>
<li><p><strong>data_board</strong> – retrieve latest price from data_board</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.backtest_brokerage.BacktestBrokerage.cancel_order">
<code class="sig-name descname">cancel_order</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">order_id</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.backtest_brokerage.BacktestBrokerage.cancel_order" title="Permalink to this definition">¶</a></dt>
<dd><p>Handle cancel order request from client.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>order_id</strong> – order id of the order to be canceled</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>no return; cancel feedback is pushed into message queue</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.backtest_brokerage.BacktestBrokerage.next_order_id">
<code class="sig-name descname">next_order_id</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.backtest_brokerage.BacktestBrokerage.next_order_id" title="Permalink to this definition">¶</a></dt>
<dd><p>Return next available order id for client to use.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>next available new order id</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.backtest_brokerage.BacktestBrokerage.on_tick">
<code class="sig-name descname">on_tick</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">tick_event</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.backtest_brokerage.BacktestBrokerage.on_tick" title="Permalink to this definition">¶</a></dt>
<dd><p>Cross standing orders against new tick_event</p>
<p>Market order can be potentially saved and then filled here against tomorrow’s open price</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>tick_event</strong> – new tick just came in</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>no return; if orders are filled, they are pushed into message queue</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.backtest_brokerage.BacktestBrokerage.place_order">
<code class="sig-name descname">place_order</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">order_event</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.backtest_brokerage.BacktestBrokerage.place_order" title="Permalink to this definition">¶</a></dt>
<dd><p>Place and fill client order; return fill event.</p>
<p>Market order is immediately filled, no latency or slippage
the alternative is to save the orders and fill in on_tick function</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>order_event</strong> – client order received</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>no return; fill_event is pushed into message queue</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.backtest_brokerage.BacktestBrokerage.reset">
<code class="sig-name descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.backtest_brokerage.BacktestBrokerage.reset" title="Permalink to this definition">¶</a></dt>
<dd><p>Reset Backtest Brokerage.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers">
<em class="property">class </em><code class="sig-prename descclassname">quanttrader.brokerage.ib_brokerage.</code><code class="sig-name descname">InteractiveBrokers</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">msg_event_engine</span></em>, <em class="sig-param"><span class="n">tick_event_engine</span></em>, <em class="sig-param"><span class="n">account</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers" title="Permalink to this definition">¶</a></dt>
<dd><dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.__init__">
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">msg_event_engine</span></em>, <em class="sig-param"><span class="n">tick_event_engine</span></em>, <em class="sig-param"><span class="n">account</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize InteractiveBrokers brokerage.</p>
<p>Currently, the client is strongly coupled to broker without an incoming queue,
e.g. client calls broker.place_order to place order directly.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>msg_event_engine</strong> – used to broadcast messages the broker generates back to client</p></li>
<li><p><strong>tick_event_engine</strong> – used to broadcast market data back to client</p></li>
<li><p><strong>account</strong> – the IB account</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.cancel_all_orders">
<code class="sig-name descname">cancel_all_orders</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.cancel_all_orders" title="Permalink to this definition">¶</a></dt>
<dd><p>Cancel all standing orders, for example, before one wants to shut down completely for some reasons.</p>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.cancel_historical_data">
<code class="sig-name descname">cancel_historical_data</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">reqid</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.cancel_historical_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Cancel historical data request. Usually not necessary.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>reqid</strong> – the historical data request id</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.cancel_order">
<code class="sig-name descname">cancel_order</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">order_id</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.cancel_order" title="Permalink to this definition">¶</a></dt>
<dd><p>Cancel client order.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>order_id</strong> – order id of the order to be canceled</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>no return. If order is successfully canceled, IB will return an orderstatus message.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.connect">
<code class="sig-name descname">connect</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">host</span><span class="o">=</span><span class="default_value">'127.0.0.1'</span></em>, <em class="sig-param"><span class="n">port</span><span class="o">=</span><span class="default_value">7497</span></em>, <em class="sig-param"><span class="n">clientId</span><span class="o">=</span><span class="default_value">0</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.connect" title="Permalink to this definition">¶</a></dt>
<dd><p>Connect to IB. Request open orders under clientid upon successful connection.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>host</strong> – host address</p></li>
<li><p><strong>port</strong> – socket port</p></li>
<li><p><strong>clientId</strong> – client id</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.contract_to_symbol">
<em class="property">static </em><code class="sig-name descname">contract_to_symbol</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">ib_contract</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.contract_to_symbol" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert IB contract to full symbol</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>ib_contract</strong> – IB contract</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>full symbol</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.disconnect">
<code class="sig-name descname">disconnect</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.disconnect" title="Permalink to this definition">¶</a></dt>
<dd><p>Disconnect from IB</p>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.heartbeat">
<code class="sig-name descname">heartbeat</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.heartbeat" title="Permalink to this definition">¶</a></dt>
<dd><p>Request server time as heartbeat</p>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.ib_order_to_order">
<em class="property">static </em><code class="sig-name descname">ib_order_to_order</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">ib_order</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.ib_order_to_order" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert IB order to order event</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>ib_order</strong> – IB representation of order</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>internal representation of order</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.log">
<code class="sig-name descname">log</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">msg</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.log" title="Permalink to this definition">¶</a></dt>
<dd><p>Broadcast server log message through message queue</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>msg</strong> – message to be broadcast</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>no return; log meesage is placed into message queue</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.next_order_id">
<code class="sig-name descname">next_order_id</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.next_order_id" title="Permalink to this definition">¶</a></dt>
<dd><p>Return next available order id</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>next order id available for next orders</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.order_to_ib_order">
<em class="property">static </em><code class="sig-name descname">order_to_ib_order</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">order_event</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.order_to_ib_order" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert order event to IB order</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>order_event</strong> – internal representation of order</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>IB representation of order</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.place_order">
<code class="sig-name descname">place_order</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">order_event</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.place_order" title="Permalink to this definition">¶</a></dt>
<dd><p>Place order to IB</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>order_event</strong> – client order to be placed</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>no return. An order event is pushed to message queue with order status Acknowledged</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.reqCurrentTime">
<code class="sig-name descname">reqCurrentTime</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.reqCurrentTime" title="Permalink to this definition">¶</a></dt>
<dd><p>Request server time on broker side</p>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.request_historical_data">
<code class="sig-name descname">request_historical_data</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">symbol</span></em>, <em class="sig-param"><span class="n">end</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.request_historical_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Request 1800 S (30 mins) historical bar data from Interactive Brokers.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>symbol</strong> – the contract whose historical data is requested</p></li>
<li><p><strong>end</strong> – the end time of the historical data</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>no returns; data is broadcasted through message queue</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.request_historical_ticks">
<code class="sig-name descname">request_historical_ticks</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">symbol</span></em>, <em class="sig-param"><span class="n">start_time</span></em>, <em class="sig-param"><span class="n">reqtype</span><span class="o">=</span><span class="default_value">'TICKS'</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.request_historical_ticks" title="Permalink to this definition">¶</a></dt>
<dd><p>Request historical time and sales data from Interactive Brokers.
See here <a class="reference external" href="https://interactivebrokers.github.io/tws-api/historical_time_and_sales.html">https://interactivebrokers.github.io/tws-api/historical_time_and_sales.html</a></p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>symbol</strong> – the contract whose historical data is requested</p></li>
<li><p><strong>start_time</strong> – i.e. “20170701 12:01:00”. Uses TWS timezone specified at login</p></li>
<li><p><strong>reqtype</strong> – TRADES, BID_ASK, or MIDPOINT</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>no returns; data is broadcasted through message queue</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.setServerLogLevel">
<code class="sig-name descname">setServerLogLevel</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">level</span><span class="o">=</span><span class="default_value">1</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.setServerLogLevel" title="Permalink to this definition">¶</a></dt>
<dd><p>Set server side log level or the log messages received from server.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>level</strong> – log level</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.subscribe_account_summary">
<code class="sig-name descname">subscribe_account_summary</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.subscribe_account_summary" title="Permalink to this definition">¶</a></dt>
<dd><p>Request account summary from broker</p>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.subscribe_market_data">
<code class="sig-name descname">subscribe_market_data</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">sym</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.subscribe_market_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Subscribe market L1 data. Market data for this symbol will then be streamed to client.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>sym</strong> – the symbol to be subscribed.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.subscribe_market_datas">
<code class="sig-name descname">subscribe_market_datas</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.subscribe_market_datas" title="Permalink to this definition">¶</a></dt>
<dd><p>Subscribe market L1 data for all symbols used in strategies. Market data for this symbol will then be streamed to client.</p>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.subscribe_market_depth">
<code class="sig-name descname">subscribe_market_depth</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">sym</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.subscribe_market_depth" title="Permalink to this definition">¶</a></dt>
<dd><p>Subscribe market L2 data. Market data for this symbol will then be streamed to client.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>sym</strong> – the symbol to be subscribed.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.subscribe_positions">
<code class="sig-name descname">subscribe_positions</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.subscribe_positions" title="Permalink to this definition">¶</a></dt>
<dd><p>Request existing positions from broker</p>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.symbol_to_contract">
<em class="property">static </em><code class="sig-name descname">symbol_to_contract</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">symbol</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.symbol_to_contract" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert fulll symbol string to IB contract</p>
<p>TODO
CL.HO BAG 174230608 1 NYMEX 257430162 1 NYMEX NYMEX     # Inter-comdty
ES.NQ BAG 371749798 1 GLOBEX 371749745 1 GLOBEX GLOBEX     # Inter-comdty
CL.HO BAG 257430162 1 NYMEX 174230608 1 NYMEX NYMEX</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>symbol</strong> – full symbol, e.g. AMZN STK SMART</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>IB contract</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.unsubscribe_account_summary">
<code class="sig-name descname">unsubscribe_account_summary</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.unsubscribe_account_summary" title="Permalink to this definition">¶</a></dt>
<dd><p>Stop receiving account summary from broker</p>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.unsubscribe_market_data">
<code class="sig-name descname">unsubscribe_market_data</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">sym</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.unsubscribe_market_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Unsubscribe market L1 data. Market data for this symbol will stop streaming to client.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>sym</strong> – the symbol to be subscribed.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.unsubscribe_market_depth">
<code class="sig-name descname">unsubscribe_market_depth</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">sym</span></em><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.unsubscribe_market_depth" title="Permalink to this definition">¶</a></dt>
<dd><p>Unsubscribe market L2 data. Market data for this symbol will stop streaming to client.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>sym</strong> – the symbol to be subscribed.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="quanttrader.brokerage.ib_brokerage.InteractiveBrokers.unsubscribe_positions">
<code class="sig-name descname">unsubscribe_positions</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quanttrader.brokerage.ib_brokerage.InteractiveBrokers.unsubscribe_positions" title="Permalink to this definition">¶</a></dt>
<dd><p>Stop receiving existing position message from broker.</p>
</dd></dl>

</dd></dl>

</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="data.html" class="btn btn-neutral float-right" title="Data" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="ordertype.html" class="btn btn-neutral float-left" title="Orders Supported" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        
        &copy; Copyright 2020, Letian Wang

    </p>
  </div>
    
    
    
    Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>